package cn.fenqing168.springcloud.service;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.cloud.stream.messaging.Sink;
import org.springframework.messaging.Message;

import java.util.Map;

/**
 * @author Administrator
 */
@EnableBinding(Sink.class)
@Slf4j
public class MessageConsumerService {

    /**
     * 注入配置文件中端口号
     */
    @Value("${server.port}")
    private String port;

    @StreamListener(Sink.INPUT)
    public void message(Message<Map<String, Object>> message){
        log.info("{}，接收到消息：{}", port, message.getPayload());
    }

}
